<?php htmlTemplate('admin_header_frame.php');?>
<table width="100%" cellspacing="1" cellpadding="3" id="listTable">
<tr>
		<th align="left" style="font-weight: bold;color:#005EAC;">&nbsp;&nbsp;
		<input type="button" value="添加栏目" onclick="addcolumns('0');">&nbsp;&nbsp;
		</th>
		<th>&nbsp;
		</th>
		
</tr>
	<?php if($list){ foreach ($list as $key=>$value):?>
	<tr >
		<td >&nbsp;&nbsp;
		<?php echo $value['cname'].' ('.$value['ename'].')';?>
		</td>
		<td align="right">
		<input type="button" value="添加子栏目" onclick="addcolumns('<?php echo $value['id'];?>');">&nbsp;&nbsp;
		<input type="button" value="修改" onclick="upcolumns('<?php echo $value['id'];?>','<?php echo $value['cname'];?>','<?php echo $value['ename'];?>','<?php echo $value['title'];?>','<?php echo $value['keywords'];?>','<?php echo $value['description'];?>');">&nbsp;&nbsp;
		<input type="button" value="删除" onclick="getUrl('<?php echo MVC_WWW_HOST.'admin/home/columns/do/del/id/'.$value['id'];?>',1,1,'确认删除  <?php echo $value['cname']?>？')">&nbsp;&nbsp;
		</td>
	</tr>	
		<?php
		if(@$value['child']){
		foreach ($value['child'] as $k=>$v):?>
			<tr >
				<td>&nbsp;&nbsp;
				|----- <?php echo $v['cname'].' ('.$v['ename'].')';?>
				</td>
				<td align="right">
				
				<input type="button" value="修改" onclick="upcolumns('<?php echo $v['id'];?>','<?php echo $v['cname'];?>','<?php echo $v['ename'];?>','<?php echo $v['title'];?>','<?php echo $v['keywords'];?>','<?php echo $v['description'];?>');">&nbsp;&nbsp;
				<input type="button" value="删除" onclick="getUrl('<?php echo MVC_WWW_HOST.'admin/home/columns/do/del/id/'.$v['id'];?>',1,1,'确认删除  <?php echo $v['cname']?>？')">&nbsp;&nbsp;
				</td>
			</tr>	
		<?php endforeach;}?>
	<?php endforeach;}?>

</table>
<div id="addculmns" style="text-align: center;padding:20px;line-height:30px;color:#333;display:none;">
<table>
<tr><td align="right"><input type="hidden" id="upid" />中文名：</td><td align="left"><input type="text" id="cname" /></td></tr>
<tr><td align="right">英文名：</td><td align="left"><input type="text" id="ename" /></td></tr>
<tr><td align="right">头部title：</td><td align="left"><textarea id="title" style="width:200px;height:40px;"></textarea></td></tr>
<tr><td align="right">头部keywords：</td><td align="left"><textarea id="keywords"  style="width:200px;height:40px;"></textarea></td></tr>
<tr><td align="right">头部description·：</td><td align="left"><textarea id="description"  style="width:200px;height:40px;"></textarea></td></tr>
<tr><td colspan="2""><input type="button" onclick="addColumns(0);" value="确 认" /></td></tr>
</table>


</div>
<div id="saveculmns" style="text-align: center;padding:20px;line-height:30px;color:#333;display:none;">
<table>
<tr><td align="right"><input type="hidden" id="upid" />中文名：</td><td align="left"><input type="text" id="upcname" /></td></tr>
<tr><td align="right">英文名：</td><td align="left"><input type="text" id="upename" /></td></tr>
<tr><td align="right">头部title：</td><td align="left"><textarea id="uptitle" style="width:200px;height:40px;"></textarea></td></tr>
<tr><td align="right">头部keywords：</td><td align="left"><textarea id="upkeywords"  style="width:200px;height:40px;"></textarea></td></tr>
<tr><td align="right">头部description·：</td><td align="left"><textarea id="updescription"  style="width:200px;height:40px;"></textarea></td></tr>
<tr><td colspan="2""><input type="button" onclick="saveColumns();" value="确 认" /></td></tr>
</table>
</div>
<script type="text/javascript">
<!--
function upcolumns(id,cname,ename,title,keywords,description)
{
	$("#upid").val(id);
	$("#upcname").val(cname);
	$("#upename").val(ename);
	$("#uptitle").val(title);
	$("#upkeywords").val(keywords);
	$("#updescription").val(description);
	showWin('saveculmns','',330);
}

var pid = 0;
function addcolumns(id){
	pid = id;
	showWin('addculmns','',330);
}
function addColumns(){
	var cname=$.trim($("#cname").val());
	var ename=$.trim($("#ename").val());
	var title=$.trim($("#title").val());
	var keywords=$.trim($("#keywords").val());
	var description=$.trim($("#description").val());
	var url = '<?php echo MVC_WWW_HOST.'admin/home/columns/do/add/pid/'?>'+pid;
	$.getJSON(url,{"cname":cname,"ename":ename,"title":title,"keywords":keywords,"description":description},function(rs){
		if(rs.status==1){
			parent.showAlert(rs.html);
			setTimeout(function(e){
				window.location.reload();
			},3000);
		}else{
			parent.showAlert(rs.html);
		}
		
	})
}
function saveColumns()
{
	var id=$.trim($("#upid").val());
	var cname=$.trim($("#upcname").val());
	var ename=$.trim($("#upename").val());
	var title=$.trim($("#uptitle").val());
	var keywords=$.trim($("#upkeywords").val());
	var description=$.trim($("#updescription").val());
	var url = '<?php echo MVC_WWW_HOST.'admin/home/columns/do/modify/id/'?>'+id;
	
	$.getJSON(url,{"cname":cname,"ename":ename,"title":title,"keywords":keywords,"description":description},function(rs){
		if(rs.status==1){
			parent.showAlert(rs.html);
			setTimeout(function(e){
				window.location.reload();
			},3000);
		}else{
			parent.showAlert(rs.html);
		}
		
	})
}
//-->
</script>